package com.xiaoxing.salesclient.mvp.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.utils.SharedPreferencesHelper;
import com.xiaoxing.salesclient.mvp.model.entity.AppointDoctor;

import java.util.List;

import me.jessyan.armscomponent.commonsdk.core.RouterHub;
import me.jessyan.armscomponent.commonsdk.utils.Utils;
import xiaoxing.com.salesclient.R;


public class YuYueChaXunAdapter extends BaseQuickAdapter<AppointDoctor.DataBean, BaseViewHolder> {

    private Context mContext;
    private SharedPreferencesHelper mSharedPreferencesHelper;

    public YuYueChaXunAdapter(Context context, @Nullable List<AppointDoctor.DataBean> data) {
        super(R.layout.item_yu_yue_cha_xun, data);
        this.mContext = context;
        mSharedPreferencesHelper = SharedPreferencesHelper.getInstance(mContext);
    }

    @Override
    protected void convert(BaseViewHolder helper, AppointDoctor.DataBean item) {

        helper.setOnClickListener(R.id.ll_yu_yue_shi_jian, new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                mSharedPreferencesHelper.putBean("appointDoctor_DataBean", item);
                Utils.navigation(mContext, RouterHub.SALES_CLIENT_YU_YUE_SHI_JIAN_ACTIVITY);

            }
        });
        helper.setOnClickListener(R.id.ll_yi_shi_xiang_qing, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Utils.navigation(mContext, RouterHub.SALES_CLIENT_YI_SHI_XIANG_QING_ACTIVITY);
                ARouter.getInstance().build(RouterHub.SALES_CLIENT_YI_SHI_XIANG_QING_ACTIVITY).withString("doctor_id", item.getDoctor_id()).navigation();
            }
        });
        helper.setOnClickListener(R.id.ll_zhu_yi_shi_xiang, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Utils.navigation(mContext, RouterHub.SALES_CLIENT_ZHU_YI_SHI_XIANG_ACTIVITY);
            }
        });

        helper.setText(R.id.tv_name, item.getDoctor_name());
        helper.setText(R.id.tv_time, item.getAppoint());
        helper.setText(R.id.tv_yi_shi_name, item.getDoctor_name());
        Glide.with(mContext).load(item.getCover()).into((ImageView) helper.getView(R.id.img_head));
    }

}
